package com.itheima.stock.controller;

import com.itheima.stock.common.domain.InnerMarketDomain;
import com.itheima.stock.common.domain.StockBlockDomain;
import com.itheima.stock.common.domain.StockUpdownDomain;
import com.itheima.stock.pojo.StockBusiness;
import com.itheima.stock.service.StockService;
import com.itheima.stock.vo.resp.PageResult;
import com.itheima.stock.vo.resp.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/quot")
@CrossOrigin
public class StockController {

    @Autowired
    private StockService service;

    @GetMapping("/stock/updown")
    public R<Map> getStockUpDown(){
        return service.stockUpDownScopeCount();
    }

    @GetMapping("/stock/tradevol")
    public R<Map> stockTradeVol4InnerMarket() {
        return service.stockTradeVol4InnerMarket();
    }

    @GetMapping("/stock/export")
    public void stockExport(HttpServletResponse response,Integer page,Integer pageSize){
        service.stockExport(response,page,pageSize);
    }

    @GetMapping("/stock/updown/count")
    public R<Map> upDownCount(){
        return service.upDownCount();
    }

    @GetMapping("/stock/all")
    public R<PageResult<StockUpdownDomain>> stockPage(Integer page,Integer pageSize){
        return service.stockPage(page,pageSize);
    }

    @GetMapping("//stock/increase")
    public R<List<StockUpdownDomain>> stockIncreaseLimit(){
        return service.stockIncreaseLimit();
    }

    @GetMapping("/sector/all")
    public R<List<StockBlockDomain>> sectorAll(){
        return service.sectorAllLimit();
    }

    @GetMapping("/stock/business/all")
    public List<StockBusiness> getAllStockBusiness(){
        return service.getAllStockBusiness();
    }

    @GetMapping("/index/all")
    public R<List<InnerMarketDomain>> innerIndexAll(){
        return service.innerIndexAll();
    }

}
